<?php
 
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
 
class AreasControllerArea extends AreasController
{
        function __construct()
        {
                parent::__construct();
 
                // Register Extra tasks
                $this->registerTask( 'add'  ,   'edit', 'remove' );
        }
 
        function add() {
		$this->edit();
	}

        /**
         * display the edit form
         * @return void
         */
        function edit()
        {
                JRequest::setVar( 'view', 'area' );
                JRequest::setVar( 'layout', 'form'  );
                JRequest::setVar('hidemainmenu', 1);
 
                parent::display();
        }

	/**
	 * save a record (and redirect to main page)
	 * @return void
	 */
	function save()
	{
		$model = $this->getModel('area');

		if ($model->store($post)) {
			$msg = JText::_( 'Area guardada!' );
		} else {
			$msg = JText::_( 'Error guardando area' );
		}

		// Check the table in so it can be edited.... we are done with it anyway
		$link = 'index.php?option=com_areas';
		$this->setRedirect($link, $msg);
	}

	/**
	 * remove record(s)
	 * @return void
	 */
	function remove()
	{
		$model = $this->getModel('area');
		if(!$model->delete()) {
			$msg = JText::_( 'Error: Una o mas areas no pudieron ser borradas.' );
		} else {
			$msg = JText::_( 'Area(s) borrada(s)' );
		}

		$this->setRedirect( 'index.php?option=com_areas', $msg );
	}

	/**
	 * cancel editing a record
	 * @return void
	 */
	function cancel()
	{
		$msg = JText::_( 'Operation Cancelled' );
		$this->setRedirect( 'index.php?option=com_areas', $msg );
	}
}
